This is a test run with generic Evergreen def file, and a range of the thresholds that determine the growing season in the drought phenology model.

This was using 4383600 runs. Most of them return a flat LAI value that is either always sensecing or has very little growth, but going to filter out the runs that don’t do that and check the ranges of VPD and psi.

LAI seems to rely on the minimum VPD threshold for the growing season the most, which makes sense.

## `summarise()` ungrouping output (override with `.groups` argument)

combine output and look at individual params

trying to filter out which runs actually show seasonal LAI.

read_filt <- read %>% 
  group_by(month, run) %>% summarize_at(vars(lai), funs(max))

ggplot(read_filt) + geom_boxplot(aes(x=as.factor(month), y=lai)) + 
  ggtitle("max monthly LAI")

read_mo <- dcast(read_filt, run ~ month, value.var='lai', .fun=mean) %>% 
  dplyr::filter(`6` < `1` & `6` < `10`)

read_mo_melt <- melt(read_mo, id.vars = 'run', variable.name = 'month', value.name = 'lai')
ggplot(read_mo_melt) + geom_boxplot(aes(x=as.factor(month), y=lai))

read2 <- read[read$run %in% read_mo_melt$run,]

ggplot(read2) + geom_line(aes(x=date, y=lai, col=as.factor(run)), show.legend = F)

rd_wy <- mkdate(sann)
rd_wysum <- rd_wy %>% group_by(month, run) %>% summarize_at(vars(lai, plantc, vpd, gsi, psi, epc_day_leafoff, epc_day_leafon), funs(max))

ggplot(rd_wysum) + geom_line(aes(x=month, y=lai, col=as.factor(run)), show.legend=F) 

#  geom_vline(aes(xintercept=150)) + 
#  geom_vline(aes(xintercept=210)) 

ggplot(rd_wysum) + geom_line(aes(x=month, y=vpd, col=as.factor(run)), show.legend=F)

ggplot(rd_wysum) + geom_line(aes(x=month, y=psi, col=as.factor(run)), show.legend=F)

ggplot(rd_wysum) + geom_line(aes(x=month, y=gsi, col=as.factor(run)), show.legend=F) + 
  geom_vline(aes(xintercept=273)) 

#### filter out which have the largest value in january or dec
filt_rd <- rd_wy %>% group_by(month, run) %>% summarize_at(vars(lai, epc_day_leafoff, epc_day_leafon, epc_ndays_expand, epc_ndays_litfall), funs(mean))

filt_rd_max <- filt_rd %>% group_by(run) %>%
  dplyr::filter(lai == max(lai)) %>% 
  dplyr::filter(month==1 | month==12)

toplot <- filt_rd[filt_rd$run %in% filt_rd_max$run,] 
ggplot(toplot) + geom_line(aes(x=month, y=lai, col=as.factor(run)), show.legend = F)

ggplot(filt_rd_max) + geom_density(aes(x=epc_day_leafon))

ggplot(filt_rd_max) + geom_density(aes(x=epc_day_leafoff))

ggplot(filt_rd_max) + geom_density(aes(x=epc_ndays_litfall))

ggplot(filt_rd_max) + geom_density(aes(x=epc_ndays_expand))